<?php $this->pageTitle=Yii::app()->name . ' - '.AdminModule::t("Profile");
$this->breadcrumbs=array(
	//AdminModule::t("Profile")=>array('profile'),
	AdminModule::t("Edit"),
);
?>
<?php echo $this->renderPartial('menu'); ?>

<?php if(Yii::app()->user->hasFlash('profileMessage')): ?>
<div class="success">
<?php echo Yii::app()->user->getFlash('profileMessage'); ?>
</div>
<?php endif; ?>
<div class="admin_table">
<h1><?php echo AdminModule::t('Edit profile'); ?></h1>
	
<div class="link">
<?php echo CHtml::link('Change Password',ApplicationConfig::getURL("admin", "profile", "changepassword"),array('class'=>'search-button')); ?>
</div>

<?php $form=$this->beginWidget('UActiveForm', array(
	'id'=>'profile-form',
	'enableAjaxValidation'=>true,
	'htmlOptions' => array('enctype'=>'multipart/form-data'),
)); ?>

	<p class="note"><?php echo AdminModule::t('Fields with <span class="required">*</span> are required.'); ?></p>

	<?php //echo $form->errorSummary(array($model,$profile)); ?>

<?php 
/*		$profileFields=$profile->getFields();
		if ($profileFields) {
			foreach($profileFields as $field) {
			?>
	<div class="row">
		<?php echo $form->labelEx($profile,$field->varname);
		
		if ($field->widgetEdit($profile)) {
			echo $field->widgetEdit($profile);
		} elseif ($field->range) {
			echo $form->dropDownList($profile,$field->varname,Profile::range($field->range));
		} elseif ($field->field_type=="TEXT") {
			echo $form->textArea($profile,$field->varname,array('rows'=>6, 'cols'=>50));
		} else {
			echo $form->textField($profile,$field->varname,array('size'=>60,'maxlength'=>(($field->field_size)?$field->field_size:255)));
		}
		echo $form->error($profile,$field->varname); ?>
	</div>	
			<?php
			}
		}*/
?>
	<div class="row">
		<?php echo $form->labelEx($model,'first_name'); ?>
		<?php echo $form->textField($model,'first_name',array('size'=>20,'maxlength'=>20)); ?>
		<?php echo $form->error($model,'first_name'); ?>
	</div>
	<div class="row">
		<?php echo $form->labelEx($model,'last_name'); ?>
		<?php echo $form->textField($model,'last_name',array('size'=>20,'maxlength'=>20)); ?>
		<?php echo $form->error($model,'last_name'); ?>
	</div>
	
	<div class="row">
		<?php echo $form->labelEx($model,'emailID'); ?>
		<?php echo $form->textField($model,'emailID',array('size'=>60,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'emailID'); ?>
	</div>
	
	<?php if($model->role_id=="2"){?>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_name'); ?>
		<?php echo CHtml::activeTextField($modelVendor,'vendor_name',array()); ?>
		<?php echo CHtml::error($modelVendor,'vendor_name'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_stateID'); ?>
		<?php echo CHtml::activeDropDownList($modelVendor,'vendor_stateID',State::getList('STATE-LIST', array()),array('empty'=>'Select State','ajax' => array(
			'type'=>'POST', //request type
			'url'=>ApplicationConfig::getURL("", "main", "searchValueCities", array()), //url to call.
			//Style: CController::createUrl('currentController/methodToCall')
			'update'=>'#Vendor_vendor_cityID', //selector to update
			//'data'=>'js:javascript statement' 
			//leave out the data key to pass all form values through
			))); ?>
		<?php echo CHtml::error($modelVendor,'vendor_stateID'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_cityID'); ?>
		<?php echo CHtml::activeDropDownList($modelVendor,'vendor_cityID',array(),array('empty'=>'Select City')); ?>
		<?php echo CHtml::error($modelVendor,'vendor_cityID'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_type'); ?>
		<?php echo CHtml::activeDropDownList($modelVendor,'vendor_type',ApplicationConfig::app()->params['vendor_params']['type'],array('empty'=>'Select Type')); ?>
		<?php echo CHtml::error($modelVendor,'vendor_type'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_address',array('style'=>'position:absolute')); ?>
		<?php echo CHtml::activeTextArea($modelVendor,'vendor_address',array('style'=>'margin-left:23%')); ?>
		<?php echo CHtml::error($modelVendor,'vendor_address'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'subscription_email'); ?>
		<?php echo CHtml::activeTextField($modelVendor,'subscription_email',array()); ?>
		<?php echo CHtml::error($modelVendor,'subscription_email'); ?>
		</div>
		<div class="row">
		<?php echo CHtml::activeLabelEx($modelVendor,'vendor_logo_file'); ?>
		<?php echo CHtml::activeFileField($modelVendor,'vendor_logo_file',array()); ?>
		<?php echo CHtml::error($modelVendor,'vendor_logo_file'); ?>
		<?php if ($modelVendor->vendor_logo_file){?>
		<img src="<?php echo ApplicationConfig::getImageUrl('VENDOR-IMAGES', array('file_name'=>$modelVendor->vendor_logo_file))?>" width="100px" height="80px">
		<?php }?>
		</div>
	<?php }?>
    <div class="clear"></div><br />

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? AdminModule::t('Create') : AdminModule::t('Save')); ?>
	</div>

<script type="text/javascript">
$(document).ready(function() {

	if($('#Vendor_vendor_stateID').val()){
	 <?php
             echo(CHtml::ajax(array
             (
                     'url'=>array(ApplicationConfig::getURL("", "main", "searchValueCities", array('stateID'=>$modelVendor->vendor_stateID,'cityID'=>$modelVendor->vendor_cityID))),
                     'update'=>'#Vendor_vendor_cityID',
             )));
     ?>
     
 	}
});
</script>
<?php $this->endWidget(); ?>

</div><!-- form -->
